package util.content;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class SpiderContentTxtMend {

	public void SpiderPageContent(String site) {

		Connection conn = null;
		Statement stmt = null;
		java.sql.ResultSet rs = null;
		final String dBHost = "192.168.0.4";
		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection("jdbc:mysql://" + dBHost + "/" + dBName + "?user=root");
			stmt = conn.createStatement();
			rs = stmt.executeQuery("select * from content where pageURL = '" + site + "'");
			while (rs.next()) {
				title = rs.getString("title");
				bodyString = rs.getString("content");
			}
			
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {
				if (rs != null) {
					rs.close();
					rs = null;
				}
				if (stmt != null) {
					stmt.close();
					stmt = null;
				}
				if (conn != null) {
					conn.close();
					conn = null;
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}

		}
	}

	String dBName = null;

	public void setdBName(String dBName) {
		this.dBName = dBName;
	}

	String title = "0";
	String bodyString = "0";

	public String getWebSiteBodyString() {
		String bodyString = this.bodyString;
		// System.out.println(bodyString);
		return bodyString;
	}

	public String getTitle() {

		String title = this.title;
		// System.out.println(title);
		return title;
	}

}
